package com.open.capacity.finance.controller;

import java.util.List;
import java.util.Map;

import com.open.capacity.commons.Result;
import com.open.capacity.finance.dto.AuditModelAuthorizes;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.security.access.prepost.PreAuthorize;
import com.open.capacity.finance.entity.AuditModelWarnScope;
import com.open.capacity.finance.service.AuditModelWarnScopeService;

import com.open.capacity.commons.PageResult;

import javax.validation.Valid;

/**
 * 模型告警人员范围配置
 *
 * @author
 * @email
 * @date 2023-02-16 16:06:50
 */
@RestController
@RequestMapping("auditmodelwarnscopes")
@Api(tags = "模型告警人员范围配置")
public class AuditModelWarnScopeController {

    @Autowired
    private AuditModelWarnScopeService auditModelWarnScopeService;


    /**
     * 查询单条记录
     */
    @RequestMapping("/findByModelId")
    @PreAuthorize("hasAnyAuthority('audit_model_warn_scope:auditmodelwarnscope:list')")
    public Result findByModelId(String id) {
        return Result.succeed(auditModelWarnScopeService.findById(id));
    }

    /**
     * 保存
     */
    @RequestMapping("/saveOrUpdate")
    @PreAuthorize("hasAnyAuthority('audit_model_warn_scope:auditmodelwarnscope:save')")
    public Result save(@RequestBody @Valid AuditModelAuthorizes auditModelWarnScope) {
        auditModelWarnScopeService.save(auditModelWarnScope);

        return Result.succeed("保存成功");
    }


    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    @PreAuthorize("hasAnyAuthority('audit_model_warn_scope:auditmodelwarnscope:delete')")
    public Result delete(@PathVariable String id) {
        auditModelWarnScopeService.delete(id);
        return Result.succeed("删除成功");
    }
}
